﻿using System;

class Pillars
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 6 Dec 2011 Morning

        int num0 = int.Parse(Console.ReadLine());
        int num1 = int.Parse(Console.ReadLine());
        int num2 = int.Parse(Console.ReadLine());
        int num3 = int.Parse(Console.ReadLine());
        int num4 = int.Parse(Console.ReadLine());
        int num5 = int.Parse(Console.ReadLine());
        int num6 = int.Parse(Console.ReadLine());
        int num7 = int.Parse(Console.ReadLine());

        int bestColomnIndex = -1;           //в авторското решение int bestIndex = Int32.MinValue;
        int bestCount = -1;                 //в авторското решение int bestCount = Int32.MinValue;

        for (int colomnIndex = 0; colomnIndex <= 7; colomnIndex++)  //colomnIndex = Pillar
        {
            int leftCount = 0;
            for (int leftIndex = colomnIndex + 1; leftIndex <= 7; leftIndex++) //лявата част на матрицата
            {
                leftCount += (num0 >> leftIndex) & 1;
                leftCount += (num1 >> leftIndex) & 1;
                leftCount += (num2 >> leftIndex) & 1;
                leftCount += (num3 >> leftIndex) & 1;
                leftCount += (num4 >> leftIndex) & 1;
                leftCount += (num5 >> leftIndex) & 1;
                leftCount += (num6 >> leftIndex) & 1;
                leftCount += (num7 >> leftIndex) & 1;
            }

            int rightCount = 0;
            for (int rightIndex = 0; rightIndex <= colomnIndex - 1; rightIndex++) ///дясната част на матрицата
            {
                rightCount += (num0 >> rightIndex) & 1;
                rightCount += (num1 >> rightIndex) & 1;
                rightCount += (num2 >> rightIndex) & 1;
                rightCount += (num3 >> rightIndex) & 1;
                rightCount += (num4 >> rightIndex) & 1;
                rightCount += (num5 >> rightIndex) & 1;
                rightCount += (num6 >> rightIndex) & 1;
                rightCount += (num7 >> rightIndex) & 1;
            }

            if (leftCount == rightCount)
            {
                bestColomnIndex = colomnIndex;
                bestCount = leftCount;
            }
        }
        if (bestCount != -1)        // в авторското решение if (bestCount != Int32.MinValue)
        {
            Console.WriteLine(bestColomnIndex);
            Console.WriteLine(bestCount);
        }
        else
        {
            Console.WriteLine("No");
        }

    }
}

